#include <iostream>

#define ZERO 0  // 宏定义

#include <climits>

int main()
{
    using namespace std;

    short sam = SHRT_MAX;       // sam为short类型最大值32767,   short范围：-32768 ~ 32767
    unsigned short sue = sam;   // sue和sam具有相同的值32767,   unsigned short范围：0 ~ 65535

    cout << "Sam has " << sam << " dollars and Sue has " << sue;
    cout << " dollars deposited." << endl
         << "Add $1 to each account." << endl << "Now ";

    sam = sam + 1;  // 往上超出范围,回到最小值
    sue = sue + 1;  // 还在范围内

    cout << "Sam has " << sam << " dollars and Sue has " << sue;
    cout << " dollars deposited.\nPoor Sam!" << endl;

    sam = ZERO;
    sue = ZERO;

    cout << "Sam has " << sam << " dollars and Sue has " << sue;
    cout << " dollars deposited.\n";
    cout << "Take $1 from each account." << endl << "Now ";

    sam = sam - 1;  // 还在范围内
    sue = sue - 1;  // 往下超出范围，回到最大值

    cout << "Sam has " << sam << " dollars and Sue has " << sue;
    cout << " dollars deposited.\nLucky Sue!" << endl;
}